// Register sidebar_widget_expandable
BloggerExt.sidebar_widget_expandable = function() {

    // find containers to expandable.
    jQuery.each(BloggerExtOptions.sidebar_widget_expandable_ids, function(i) {
        // find widget container with class name
        var sideTitle = this;
        var sideObjs = BloggerExt.getSideObjByTitle(sideTitle);
        if (sideObjs.length >= 2) {
            var widgetId = "expandable_side_" + i;
            var titleObj = sideObjs[0];
            var contentObj = sideObjs[1];
            var animate_str = "";
            if(BloggerExtOptions.sidebar_widget_expandable_animate) {
                var animate_str = "'fast',";
            }else {
                var animate_str = ").each(";
            }
            var link = "<span class=\"sidebar-widget-expand\"><a onclick=\"jQuery('#"+widgetId+"_content').toggle("+animate_str
                      +"function(){ "
                      +"  jQuery(this).is(':hidden') ? "
                      +"  jQuery('#"+widgetId+"_title a:eq(0)').html(BloggerExtOptions.sidebar_widget_expan_title) : "
                      +"  jQuery('#"+widgetId+"_title a:eq(0)').html(BloggerExtOptions.sidebar_widget_collapse_title)"
                      +"});\">"+BloggerExtOptions.sidebar_widget_expan_title+"</a></span>";
            titleObj.prepend(link);
            titleObj.attr('id', widgetId+"_title");
            contentObj.hide();
            contentObj.attr('id', widgetId+"_content");
        }
    });

};
BloggerExt.register('sidebar_widget_expandable' ,  {
	sidebar_widget_expandable: true,
	sidebar_widget_expandable_version: 0.1,
	sidebar_widget_expandable_animate: false,
    sidebar_widget_expan_title: '[+]',
    sidebar_widget_collapse_title: '[-]',
    sidebar_widget_expandable_ids: []
});

